#ifndef K_LOCKABLE_H
#define K_LOCKABLE_H
#pragma once

#include "KMutex.h"

class KLockable : KNoCopy {
public:
    virtual ~KLockable() = 0;
protected:
    KLock &entry() const { return m_entry; }
private:
    mutable KLock m_entry;
    friend class KLocker;
    friend class KUnlocker;
};

class KLocker : KMutex {
public:
    explicit KLocker(KLockable &lockable) : KMutex(lockable.entry()) {}
};

class KUnlocker : KShare {
public:
    explicit KUnlocker(KLockable &lockable) : KShare(lockable.entry()) {}
};

#endif // K_LOCKABLE_H